package cn.jingzhuan.fm.pojo

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName


data class FMAudio (
    @SerializedName("id")  val id: String,
    @SerializedName("name") val name: String,
    @SerializedName("url") val url: String,
    @SerializedName("duration") val duration: String,
    @SerializedName("listen_count") val listenCount: String,
    @SerializedName("created_at")  val createdAt: String,
    @SerializedName("updated_at") val updatedAt: String,
    @SerializedName("album_id") val albumId: String?
) : Parcelable {
    constructor(parcel: Parcel) : this(
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString(),
            parcel.readString()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(name)
        parcel.writeString(url)
        parcel.writeString(duration)
        parcel.writeString(listenCount)
        parcel.writeString(createdAt)
        parcel.writeString(updatedAt)
        parcel.writeString(albumId)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<FMAudio> {
        override fun createFromParcel(parcel: Parcel): FMAudio {
            return FMAudio(parcel)
        }

        override fun newArray(size: Int): Array<FMAudio?> {
            return arrayOfNulls(size)
        }
    }
}